home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- // Borland C++Builder
- // Copyright (c) 1987, 1997 Borland International Inc. All Rights Reserved.
- //---------------------------------------------------------------------------
- #if !defined(ColorGrdHPP)
- #define ColorGrdHPP
- //----------------------------------------------------------------------------
- #include <Menus.hpp>
- #include <ExtCtrls.hpp>
- #include <Controls.hpp>
- #include <Forms.hpp>
- #include <Graphics.hpp>
- #include <Classes.hpp>
- #include <Messages.hpp>
- #include <Windows.hpp>
- #include <System.hpp>
- #include <consts.hpp>
-
- //-- type declarations -------------------------------------------------------
- enum TGridOrdering { go16x1, go8x2, go4x4, go2x8, go1x16 };
-
- class TColorGrid : public TCustomControl
- {
- private:
- TPaletteEntry FPaletteEntries[20];
- Boolean FClickEnablesColor;
- Integer FForegroundIndex;
- Integer FBackgroundIndex;
- Boolean FForegroundEnabled;
- Boolean FBackgroundEnabled;
- Integer FSelection;
- Integer FCellXSize;
- Integer FCellYSize;
- Integer FNumXSquares;
- Integer FNumYSquares;
- TGridOrdering FGridOrdering;
- Boolean FHasFocus;
- TNotifyEvent FOnChange;
- TMouseButton FButton;
- Boolean FButtonDown;
- void __fastcall DrawSquare(Integer Which, Boolean ShowSelector);
- void __fastcall DrawFgBg(void);
- void __fastcall UpdateCellSizes(Boolean DoRepaint);
- void __fastcall SetGridOrdering(TGridOrdering Value);
- TColor __fastcall GetForegroundColor(void);
- TColor __fastcall GetBackgroundColor(void);
- void __fastcall SetForegroundIndex(Integer Value);
- void __fastcall SetBackgroundIndex(Integer Value);
- void __fastcall SetSelection(Integer Value);
- void __fastcall EnableForeground(Boolean Value);
- void __fastcall EnableBackground(Boolean Value);
- MESSAGE void __fastcall WMSetFocus(TWMSetFocus &Message);
- MESSAGE void __fastcall WMKillFocus(TWMKillFocus &Message);
- MESSAGE void __fastcall WMGetDlgCode(TWMNoParams &Message);
- MESSAGE void __fastcall WMSize(TWMSize &Message);
- MESSAGE void __fastcall CMCtl3DChanged(TMessage &Message);
-
- protected:
- virtual void __fastcall KeyDown(Word &Key, TShiftState Shift);
- virtual void __fastcall MouseDown(TMouseButton Button, TShiftState Shift, Integer X, Integer Y);
- virtual void __fastcall MouseMove( TShiftState Shift, Integer X, Integer Y);
- virtual void __fastcall MouseUp(TMouseButton Button, TShiftState Shift, Integer X, Integer Y);
- virtual void __fastcall CreateWnd(void);
- virtual void __fastcall Paint(void);
- virtual void __fastcall Change(void);
- Integer __fastcall SquareFromPos(Integer X, Integer Y);
-
- public:
- __fastcall virtual TColorGrid(TComponent *AOwner);
- __property TColor ForegroundColor = {read=GetForegroundColor, nodefault};
- __property TColor BackgroundColor = {read=GetBackgroundColor, nodefault};
-
- __published:
- __property Boolean ClickEnablesColor = {read=FClickEnablesColor, write=FClickEnablesColor, default=0
- };
- __property Ctl3D ;
- __property DragCursor ;
- __property DragMode ;
- __property Enabled ;
- __property TGridOrdering GridOrdering = {read=FGridOrdering, write=SetGridOrdering, default=2};
- __property Integer ForegroundIndex = {read=FForegroundIndex, write=SetForegroundIndex, default=0};
- __property Integer BackgroundIndex = {read=FBackgroundIndex, write=SetBackgroundIndex, default=0};
- __property Boolean ForegroundEnabled = {read=FForegroundEnabled, write=EnableForeground, default=1}
- ;
- __property Boolean BackgroundEnabled = {read=FBackgroundEnabled, write=EnableBackground, default=1}
- ;
- __property Font ;
- __property ParentCtl3D ;
- __property ParentFont ;
- __property ParentShowHint ;
- // __property PopUpMenu ;
- __property Integer Selection = {read=FSelection, write=SetSelection, default=0};
- __property ShowHint ;
- __property TabOrder ;
- __property TabStop ;
- __property Visible ;
- __property TNotifyEvent OnChange = {read=FOnChange, write=FOnChange};
- __property OnClick ;
- __property OnDragDrop ;
- __property OnDragOver ;
- __property OnEndDrag ;
- __property OnEnter ;
- __property OnExit ;
- __property OnKeyDown ;
- __property OnKeyPress ;
- __property OnKeyUp ;
- __property OnMouseDown ;
- __property OnMouseMove ;
- __property OnMouseUp ;
- BEGIN_MESSAGE_MAP
- MESSAGE_HANDLER(WM_SIZE, TWMSize, WMSize);
- MESSAGE_HANDLER(WM_SETFOCUS, TWMSetFocus, WMSetFocus);
- MESSAGE_HANDLER(WM_KILLFOCUS, TWMKillFocus, WMKillFocus);
- MESSAGE_HANDLER(WM_GETDLGCODE, TWMNoParams, WMGetDlgCode);
- MESSAGE_HANDLER(CM_CTL3DCHANGED,TMessage, CMCtl3DChanged);
- END_MESSAGE_MAP(TCustomControl);
- };
-
- //-- var, const, procedure ---------------------------------------------------
- #define NumPaletteEntries Byte(20)
- //-- end unit ----------------------------------------------------------------
- #endif // ColorGrd
-